import java.util.Random;
import java.util.Scanner;

public class 抽卡模拟器 {
    private static final double PURPLE_PROBABILITY = 0.1;
    private static final double YELLOW_PROBABILITY_INIT = 0.006;
    private static int purpleCount = 0;
    private static int yellowCount = 0;
    private static final Random random = new Random();

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请选择抽卡方式:1. 单抽 2. 十连 3. 退出");
            int choice = scanner.nextInt();
            switch (choice) {
                case 1:
                    singleDraw();
                    break;
                case 2:
                    tenDraw();
                    break;
                case 3:
                    System.out.println("退出抽卡模拟器。");
                    scanner.close();
                    return;
                default:
                    System.out.println("无效的选择，请重新输入。");
            }
        }
    }

    public static void singleDraw() {
        double yellowProb = calculateYellowProbability();
        double rand = random.nextDouble();
        if (purpleCount == 9) {
            drawResult("紫色");
            purpleCount = 0;
            yellowCount++;
        } else if (rand < yellowProb) {
            drawResult("黄色");
            purpleCount++;
            yellowCount = 0;
        } else if (rand < yellowProb + PURPLE_PROBABILITY) {
            drawResult("紫色");
            purpleCount = 0;
            yellowCount++;
        } else {
            drawResult("蓝色");
            purpleCount++;
            yellowCount++;
        }
    }

    public static void tenDraw() {
        for (int i = 0; i < 10; i++) {
            singleDraw();
        }
    }

    private static double calculateYellowProbability() {
        if (yellowCount < 70) {
            return YELLOW_PROBABILITY_INIT;
        } else if (yellowCount >= 90) {
            return 1.0;
        } else {
            // 简单的二次函数来模拟非线性增长
            double x = (yellowCount - 70) / 20.0;
            return YELLOW_PROBABILITY_INIT + (1 - YELLOW_PROBABILITY_INIT) * x * x;
        }
    }

    private static void drawResult(String color) {
        System.out.println("抽到了：" + color);
        if ("黄色".equals(color)) {
            System.out.println("恭喜，出金了!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        }
    }
}